home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Freeware / Utilitare / Battery Eater / Plugins / API + Sample (Delphi) / TestPlugin.dpr < prev   
Encoding:
Text File  |  2004-05-31  |  4.0 KB  |  116 lines

  1. //{$DEFINE DEBUG}   // Uncomment this string if you want to debug plugin
  2.  
  3. library TestPlugin;
  4.  
  5. uses
  6.   windows,
  7.   plug in 'plug.pas';
  8.  
  9. const
  10.   PluginName : PChar = 'Test Plugin';  // plugin name
  11.   BenchName  : PChar = 'Plugin Bench';   // if plugin is "benchmark" plugin this const is a name for bench
  12.   InfoName   : PChar = 'Plugin Info';   // if plugin is "info" plugin this const is a name for info
  13.  
  14. //=============================================================================
  15. // For smaller DLL size
  16. //=============================================================================
  17. Function IntToStr( int : Integer ) : String;
  18. begin
  19.   Str(int, Result);
  20. end;
  21.  
  22. //=============================================================================
  23. // This functions transmite plugin's information, so main app can decide how
  24. // to use this plugin properly
  25. //=============================================================================
  26. Function GetPluginInfo : TPlugunInfo;
  27. begin
  28.   Result.Name:= PluginName;
  29.   Result.IsBench:= true;
  30.   Result.IsInfo:= true;
  31.   Result.BenchName:= BenchName;
  32.   Result.InfoName:= InfoName;
  33.   Result.IsUseOpenGL:= false;    // use or not default opengl window?
  34. end;
  35.  
  36. //=============================================================================
  37. // This proc is called from main app at load time and transmite application's
  38. // handle.
  39. // After that we initialize all functions, exported by main application
  40. //=============================================================================
  41. Procedure InitPlugin(_Owner : Cardinal);
  42. begin
  43.   Owner:= _Owner;
  44.   InitializePlugin;
  45. end;
  46.  
  47. //=============================================================================
  48. // This Procedure calls after main window create.
  49. // hwnd - handle of main window
  50. //=============================================================================
  51. Procedure PluginAfterStart(hwnd : Cardinal);
  52. begin
  53.   h_wnd := hwnd;
  54.  
  55.   {$IFDEF DEBUG}
  56.   MessageBox(h_wnd, 'Plugin AfterStart', PluginName, MB_OK);
  57.   {$ENDIF}
  58. end;
  59.  
  60. //=============================================================================
  61. // This Procedure calls after benchmark is started. (shift+f3 or normal start)
  62. //=============================================================================
  63. Procedure PluginStartBenchmark;
  64. begin
  65.   {$IFDEF DEBUG}
  66.   MessageBox(h_wnd, 'Benchmark started', PluginName, MB_OK);
  67.   {$ENDIF}
  68. end;
  69.  
  70. //=============================================================================
  71. // This Procedure calls in case of benchmark aborted.
  72. //=============================================================================
  73. Procedure PluginEndBenchmark;
  74. begin
  75.   {$IFDEF DEBUG}
  76.   MessageBox(h_wnd, 'Benchmark Aborted', PluginName, MB_OK);
  77.   {$ENDIF}
  78. end;
  79.  
  80. //=============================================================================
  81. // This Procedure calls in case info draws
  82. //=============================================================================
  83. Procedure PluginDrawInfo;
  84. var
  85.   PluginVersion : TplugInVersion;
  86. begin
  87.   PluginVersion:= beGetPluginVersion;
  88.   {$IFDEF DEBUG}
  89.  
  90.   {$ENDIF}
  91.   beDrawInfoText(17, 9, 10, 'Plugin API version');
  92.   beDrawInfoText(17, 41, 10, 'Plugin API revision');
  93.   beDrawInfoText(17, 73, 10, 'Plugin API comment');
  94.   beDrawInfoText(17, 105, 10, 'Plugins Loaded');
  95.  
  96.   beDrawInfoText(17, 155, 9, 'This is just simple info plugin');
  97.  
  98.   beDrawInfoText(9, 25, 7, PChar(inttostr(PluginVersion.Major) + '.' + inttostr(PluginVersion.Minor)));
  99.   beDrawInfoText(9, 57, 7, PChar(inttostr(PluginVersion.Revision)));
  100.   beDrawInfoText(9, 89, 7, PluginVersion.Comment);
  101.   beDrawInfoText(9, 121, 7,PChar(inttostr( PluginVersion.plugins)));
  102. end;
  103.  
  104. //=============================================================================
  105. // Exports Section
  106. //=============================================================================
  107. exports
  108.   GetPluginInfo,     // this two procs must be exported
  109.   InitPlugin,        // this two procs must be exported
  110.   PluginAfterStart,
  111.   PluginStartBenchmark,
  112.   PluginEndBenchmark,
  113.   PluginDrawInfo;
  114.  
  115. end.
  116.